define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'appealnew/index' + location.search,
                    // add_url: 'appealnew/add',
                    edit_url: 'appealnew/edit',
                    // del_url: 'appealnew/del',
                    // multi_url: 'appealnew/multi',
                    // import_url: 'appealnew/import',
                    table: 'appeal_new',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        // {checkbox: true},
                       {field: 'type', title: __('Type'), searchList: {"0":__('订单评价的申诉'),"1":__('橱窗的举报'),"2":__('用户的举报'),"3":__('动态的举报'),"4":__('动态评价的举报'),"5":__('动态回复的举报'),"6":__('订单评价的申诉')}, formatter: Table.api.formatter.normal},
                        // {field: 'id', title: __('Id')},
                        // {field: 'uid', title: __('Uid'), operate: 'LIKE'},
                        {field: 'username', title: __('Username'), operate: 'LIKE'},
                        {field: 'umobile', title: __('Umobile'), operate: 'LIKE'},
                        {field: 'order_sn', title: __('Order_sn'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'aid', title: __('Aid'), operate: 'LIKE'},
                        {field: 'eusername', title: __('Eusername'), operate: 'LIKE'},
                        {field: 'emobile', title: __('Emobile'), operate: 'LIKE'},
                        {field: 'e_title', title: __('E_title'), operate: 'LIKE'},
                        {field: 'e_desc', title: __('E_desc'), operate: 'LIKE'},
                        // {field: 'e_content', title: __('E_content'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'status', title: __('Status'), searchList: {"待处理":__('待处理'),"已处理":__('已处理'),"拒绝处理":__('拒绝处理'),"已取消":__('已取消')}, formatter: Table.api.formatter.status},
                        // {field: 'err_cnt', title: __('Err_cnt'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                      
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
